package com.yss.reportworld.domain.rule;

import com.yss.common.core.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 多表关联-过滤条件  操作符
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum DBOperationEnum implements BaseEnum<String> {
    /**
     * 过滤条件中的操作符
     */
    EQ("=", "等于"),
    GT(">", "大于"),
    GE(">=", "大于等于"),
    LT("<", "小于"),
    LE("<=", "小于等于"),
    NE("!=", "不等于"),
    IN("in", "包含");

    private final String code;
    private final String desc;

    public static DBOperationEnum getEnum(String code) {
        return Arrays.stream(values()).filter(b -> Objects.equals(b.code, code)).findFirst().orElse(null);
    }

    public static String getEnumDesc(String code) {
        DBOperationEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }
}
